package com.suxin.config;

import com.suxin.rpc.TPMRpc;
import feign.Feign;
import feign.Logger;
import feign.Request;
import feign.Retryer;
import feign.gson.GsonDecoder;
import feign.gson.GsonEncoder;
import feign.slf4j.Slf4jLogger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Classname RpcFeignConfig
 * @Description [ TODO ]
 * @Author Tang
 * @Date 2020/11/18 11:16
 * @Created by ASUS
 */
@Configuration
public class RpcFeignConfig {

    @Value("http://oci.hzjykj.cn")
    private String tpmUrl;

    @Bean
    public TPMRpc tpmRpc() {
        return Feign.builder()
                .options(new Request.Options(1000, 5000))
                .retryer(new Retryer.Default(500, 5000, 3))
                .encoder(new GsonEncoder())
                .decoder(new GsonDecoder())
                .logger(new Slf4jLogger())
                .logLevel(Logger.Level.FULL)
                .target(TPMRpc.class, tpmUrl);
    }

}